﻿@inject MockDataTableDynamicService DataTableDynamicService

<Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext"
       IsStriped="true" IsBordered="true" IsExcel="true"
       ShowToolbar="true" ShowDefaultButtons="false">
    <DetailRowTemplate>
        @{
            var detailContext = GetDetailDataTableDynamicContext(context);
        }
        <div class="p-2 w-100">
            <Table TItem="DynamicObject" DynamicContext="detailContext" IsStriped="true" IsBordered="true" IsExcel="true">
            </Table>
        </div>
    </DetailRowTemplate>
</Table>

@code {
    private DataTableDynamicContext? DataTableDynamicContext { get; set; }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        DataTableDynamicContext = DataTableDynamicService.CreateContext();
    }

    private DynamicObjectContext GetDetailDataTableDynamicContext(DynamicObject context) => DataTableDynamicService.CreateDetailContext(context);
}
